<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="utf-8">
    <title>物料配套申请</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta content="no-cache, no-store, must-revalidate" http-equiv="Cache-Control"/>
    <meta content="no-cache" http-equiv="Pragma"/>
    <meta content="0" http-equiv="Expires"/>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=8">
    <meta http-equiv="Expires" content="0">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Cache-control" content="no-cache">
    <meta http-equiv="Cache" content="no-cache">
    <link rel="stylesheet" href="../styles/base.css"/>
    <!--<link rel="stylesheet" href="../styles/common.css"/>-->
    <link rel="stylesheet" href="../styles/font/iconfont.css"/>
    <link rel="stylesheet" href="../js/layui/css/layui.css"  media="all">
    <style>
        body{
            background:#ddecf5;
            /*overflow: hidden;*/
        }
        body{
        }
        input{
            text-align: center;
        }
        .textTable{
            clear: both;
            margin-top: 20px;
            min-width: 100%;
            width:100%;
            height:auto;
            padding-bottom: 10px;
            overflow-x: scroll;
            position: relative;

        }
        .textTable td{
            width:50px;
            text-align: center;
            height:30px;
        }
        .tabRight thead{
            background:#eee;
        }
        .textTable .tabRight tr{
            width:auto;
        }
        .textTable .tabRight td {
            width:auto;
            min-width: 120px;
            text-align: center;
            height:30px;
        }
        .textTable .tabRight tr td:first-child{
            max-width: 50px;
            min-width: 50px;
        }
        .textTable .tabRight tr td input{
            width:90%;
            margin-left:5%;
            height:39px;
            line-height: 39px;
            font-size: 14px;
        }
        .boxContainer{
            background: #fff;
            width:94%;
            margin-left:2%;
            padding:10px 1%;
            margin-top: 10px;
            clear: both;
        }
        .layui-form{
            heigth:31px;
            overflow: hidden;
        }
        .layui-form-item{
            margin-bottom: 0;

        }
        .layui-input-block{
            margin-left: 0px;
            /* min-height: 30px*/

        }
        .layui-form [lay-ignore] {
            display: initial;
            border:none;
            min-width: 100%;
            width:auto;
            height:36px;
            line-height: 36px;
            padding: 0 2%;
            margin: 0;
        }

        .laytable-cell-1-sexc{overflow:visible;}
        .textTable .tabRight tr td .layui-input-block input{
            width:100%;
            margin-left: 0;
            border:none;
        }
        #loading{
            position:fixed;
            width:100%;
            height:100%;
            bacckground:rgba(0,0,0,0.2);
            z-index: 99999999999999999999999;
            display:none;
        }
        #loading img{
            width:100px;
            height:100px;
        }
        .submitBtns div{
            display: inline-block;
            ont: 14px "微软雅黑";
            float:right;
            background-color: #eee;
            font-family: 'Open Sans', sans-serif;
            font-size: 14px;
            text-decoration: none;
            font-weight: 600;
            color: #333;
            position: relative;
            padding: 2px 15px;
            margin-right: 15px;
            margin-top: 10px;
            border-top-right-radius: 5px;
            border-bottom-right-radius: 5px;
            border-top-left-radius: 5px;
            border-bottom-left-radius: 5px;
            background-image: -webkit-gradient( linear, left bottom, left top, color-stop(0, rgb(242,242,242)), color-stop(1, rgb(242,242,242)) );
            cursor: pointer;
        }
        .submitBtns div:hover{
            color:#fff;
            background:#40E0D0;
        }
        .layui-layer-content .layui-form{
            border:1px solid #ccc;
        }
        .tabRight tbody tr td{
            max-height:40px;
            padding:0 5px;
            max-width:260px;
            text-align: center;
            overflow: hidden;
            text-overflow:ellipsis;
            white-space: nowrap;
        }
        .tabRight tbody tr td a {
            color:#0000FF;
            cursor: pointer;
            text-decoration:underline;
            width:100%;
            text-align: center;
        }
        .createBox{
            width:100%;
            height:100%;
            position:absolute;
            z-index: 99999999999999999999999999;
            /*backgeound:rgba(0,0,0,.4);*/
            background:rgba(0,0,0,0.6);
            /*opacity:0.8;filter:Alpha(opacity=80);*/
            display:none;
        }
        .createBoxBG{
            position:fixed;
            width:400px;
            height:300px;
            left:50%;
            top:100px;
            margin-left:-200px;
        /*    margin-top:-150px;*/
            background:#fff;
            /*opacity:1;filter:Alpha(opacity=100);*/
        }
        .closeBOXDig{
            position: fixed;
            left: 50%;
            padding:4px 5px;
            background:#ccc;
            border-radius: 5px;
            border: 1px solid #ccc;
            margin-left: 200px;
            top:80px;
        }
        #pageBar2{
            display: none;
        }
    </style>
</head>
<body>
<div class="createBox">
    <span class="closeBOXDig">关闭</span>
    <div class="createBoxBG">

    </div>
</div>
<div class="boxContainer">
    <div id="loading">
        <img src='../styles/img/loading.gif' />
    </div>

    <div class="textTable">
        <!--<table class="tabLeft"  cellspacing="0" cellpadding="0" style="border-width:1px;border-style:solid;border-color:#ccc"  border="1">
            <thead><tr><th>编号</th></tr></thead>
        </table>-->
        <table class="tabRight" cellspacing="0" cellpadding="0" style="border-width:1px;border-style:solid;border-color:#ccc"  border="1">

        </table>
    </div>
    <div class="submitBtns">
        <div class="submitMes">提交</div><!--<div class="tempStorage">暂存</div>-->
    </div>
    <div style="clear:both;"></div>
</div>
</body>
<script type="text/javascript" src="../js/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="../js/common/common.js"></script>
<script type="text/javascript" src="../js/common/utils.js"></script>
<script src="../layer/layer.js" charset="utf-8"></script>
<script type="text/javascript" src="../js/common/myAjax.js"></script>
<script src="../js/pages/mateApply/typeC.js"></script>
<script src="../js/pages/mateApply/typePOL.js"></script>
<script language="Javascript" src="../jqueryNicepage/js/layui.js"></script>
<script>
    (function(){
        var height=document.body.clientHeight;
        var width =document.body.clientWidth;
        $("#loading img").css({
            "margin-left":width/2-25+"px",
            "margin-top":height/2-25+"px"
        })
        $("#loading").css({
            display:"block"
        });

        var dataListObj={};
        var oid=getQueryStringByNameTwo("oid")!=undefined?getQueryStringByNameTwo("oid"):"";
        var orEdt=getQueryStringByNameTwo("orEdt")!=undefined?getQueryStringByNameTwo("orEdt"):"";
        var itemOid=getQueryStringByNameTwo("itemOid")!=undefined?getQueryStringByNameTwo("itemOid"):"";
        if(orEdt!=""&&orEdt=="yes"){
            $(".submitBtns").css({
                "display":"block"
            })
        }else{
            $(".submitBtns").css({
                "display":"none"
            })
        }
        var data="oid="+oid+"&itemoid="+itemOid;
        MaterialReverseAjax("/MaterialsApplication/tmGetMaterialsApplication",data,function(str){
            $("#loading").css({
                display:"none"
            });
            var classtype=str.datalist!=undefined?str.datalist[0].roottype:"";
            var datalist=str.datalist;
            if(classtype=="SemiFinishedGood"){
                var publicClass=commonObj.CPublicAttName;
                var publicText=commonObj.CEditAttName;
            }else if(classtype=="Material"){
                var publicClass=commonObj.POLPublicAttName;
                var publicText=commonObj.POLEditAttName;
            }
            if(classtype=="SemiFinishedGood"){
                dataListObj={
                    "number":"",//物料编号
                    "SemiFinishedGoodType":'',//半成品分类*
                    "name":"",//物料名称
                    "synchysis":"",//是否混版及混版尺寸
                    "defaultUnit":"",//默认单位*

                    "Coatingtype":"",//镀膜类型
                    "partSingleGlassThickness":"",//单玻璃厚度*
                    "cuttingMode":"",//切割方式*
                    "processingModeAndThickness":"",//加工方式及薄化前后厚度*
                    "Integration":"",//集成度（格式如：60PANEL）*
                    "finishedGoodType":"",//成品型号
                    "classificationATT":"",//分类属性

                    "createType":"",//类型（成品/半成品）
                    "source":"",//源*
                    "partNumberEffectiveSite":"",//料号产地
                    "finishedGoodSize":"",//产品尺寸*
                    "otherorigin":"",//其他生效地及源类型（如只需在一地生效，请选“无”）
                    "finishedGoodLineBody":"",//线体*
                    "partDrawingNumber":"",//图纸编号/工艺文件编号（申请T1时必填，如：TM033HS01)）
                    "partInspectionStandard":"",//检验标准:
                    "partSupplier":"",//供应商：*
                    "partEnvProtectionCategory":"",//环保类别:*
                    "partApplicationReason":"",//申请原因
                    "partNote":""//备注说明：
                };
            }else if(classtype=="Material"){
                dataListObj={
                    "number":"",//物料编号
                    "name":"",//物料名称
                    "createType":"",//类型:
                    "defaultUnit":"",//默认单位
                    "partCName":"",//物料中文名称
                    "partDrawingNumber":'',//材料型号/图纸编号:
                    "partMainSpecification":"",//主要规格（长×宽×厚mm）
                    "absorptionShaftAngle":"",//吸收轴角度(与长边逆时针方向夹角，注：长边为靠近source IC侧的边)：
                    "polarizerType":"",//偏光片类型
                    "surfaceTreatment":"",//表面处理方式：
                    "partRecognize":"",//是否需要零件承认（POL、背光、铁框、TP、PCB（A）、FPC（A）需要零件承认）
                    /*"MtlNumofPOLBtn":"",//对应下POL料号(若已有料号，务必填写正确，涉及关联mark):
                    "MtlNumofPOLTop":"",//对应上POL料号(若已有料号，务必填写正确，涉及关联mark):*/
                    "isBothNewPolarizer":"",//上下偏光片是否均为新增(务必确认上下偏一同申请还是仅单侧申请):
                    "partDrawingNumber1":"",//上/下偏光片料号（格式例如：上偏：1040008530，下偏：1040008540）:
                    "POLResolution":"",//分辨率（长×宽）:
                    "DisplayMode":"",//显示模式:
                  /*  "MtlNumofPOLTop1":"",//对应上POL料号:"
                    "MtlNumofPOLBtn1":"",//   对应下POL料号:*/
                    "source":"",//源
                    "partEnvProtectionCategory":"",//环保类别
                    "finishedGoodType":"",//产品型号
                    "partNumberEffectiveSite":"",//料号产地
                    "partInspectionStandard":"",//检验标准:
                    "partSupplier":"",//供应商：
                    "materialClassification":"",//物料分级
                    "partRFQNumber":"",//RFQ编号（深圳用）
                    "specialMonitor":"",//是否专显
                    "partApplicationReason":"",//申请人及申请原因:
                    "partNote":"",//备注说明：
                    "partSize":""//尺寸(模组尺寸，例如：5.13、4.30等)
                };
            }
          //  {"datalist":[{"partRFQNumber":"12312","productClassDesc":"AUT-无源车载应用；AUTA-车载前装应用；AUTB-高端要求车载后装应用；AUTC-一般要求车载后装应用；INDF-无源工业应用、NLT中高端工业应用，天马特种显示、NLT普通工业；INDT-天马中高端工业；INDS-天马普通工业；AUTTP-CTP类无源车载应用；AUTATP-CTP类车载前装应用；AUTBTP-CTP类高端要求车载后装应用；AUTCTP-CTP类一般要求车载后装应用；INDFTP-CTP类无源工业应用、NLT中高端工业应用，天马特种显示、NLT普通工业；INDTTP-CTP类天马中高端工业；INDSTP-CTP类天马普通工业；CONTP-消费类应用电容触摸屏；CON-消费类产品","classificationATT":"","partCName":"虚拟偏光片组件","surfaceTreatment":"4","partEName":"Dummy Polarizer","name":"0000000424","specialMonitor":"否","defaultUnit":"EAE","whetherPartRecognize":" ","partEnvProtectionCategory":"Q/S0002+BF","absorptionShaftAngle":"3","partInspectionStandard":"特殊标准-Amazon","partCostUnit":"人民币","createType":"原材料","partIncomingInspection":"直接接收","polarizerType":"NV","roottype":"Material","number":"0000011837","partSupplier":"1231","materialClassification":"INDT","partNote":"12312","partDrawingNumber":"8","partApplicationReason":"12312","partSize":"1231","finishedGoodType":"W123","source":"make","DisplayMode":"9","partMainSpecification":"2","isSecondSupplier":"否","partNumberEffectiveSite":"F10（武汉天马）","partRecognize":"否"},{"partRFQNumber":"12312","productClassDesc":"AUT-无源车载应用；AUTA-车载前装应用；AUTB-高端要求车载后装应用；AUTC-一般要求车载后装应用；INDF-无源工业应用、NLT中高端工业应用，天马特种显示、NLT普通工业；INDT-天马中高端工业；INDS-天马普通工业；AUTTP-CTP类无源车载应用；AUTATP-CTP类车载前装应用；AUTBTP-CTP类高端要求车载后装应用；AUTCTP-CTP类一般要求车载后装应用；INDFTP-CTP类无源工业应用、NLT中高端工业应用，天马特种显示、NLT普通工业；INDTTP-CTP类天马中高端工业；INDSTP-CTP类天马普通工业；CONTP-消费类应用电容触摸屏；CON-消费类产品","classificationATT":"","isBothNewPolarizer":"7","partCName":"下偏光片","partEName":"Polarizer","surfaceTreatment":"4","name":"0000000423","specialMonitor":"否","defaultUnit":"EAE","whetherPartRecognize":" ","partEnvProtectionCategory":"Q/S0002+BF","absorptionShaftAngle":"3","partInspectionStandard":"特殊标准-Amazon","partCostUnit":"人民币","MtlNumofPOLTop":"6","createType":"原材料","partIncomingInspection":"IQC","polarizerType":"NV","roottype":"Material","number":"0000011836","partSupplier":"1231","materialClassification":"INDT","partNote":"12312","partDrawingNumber":"1","partApplicationReason":"12312","partSize":"1231","finishedGoodType":"W123","source":"make","partMainSpecification":"2","isSecondSupplier":"否","partNumberEffectiveSite":"F10（武汉天马）","partRecognize":"是"},{"partRFQNumber":"12312","productClassDesc":"AUT-无源车载应用；AUTA-车载前装应用；AUTB-高端要求车载后装应用；AUTC-一般要求车载后装应用；INDF-无源工业应用、NLT中高端工业应用，天马特种显示、NLT普通工业；INDT-天马中高端工业；INDS-天马普通工业；AUTTP-CTP类无源车载应用；AUTATP-CTP类车载前装应用；AUTBTP-CTP类高端要求车载后装应用；AUTCTP-CTP类一般要求车载后装应用；INDFTP-CTP类无源工业应用、NLT中高端工业应用，天马特种显示、NLT普通工业；INDTTP-CTP类天马中高端工业；INDSTP-CTP类天马普通工业；CONTP-消费类应用电容触摸屏；CON-消费类产品","classificationATT":"","isBothNewPolarizer":"7","partCName":"上偏光片","partEName":"Polarizer","surfaceTreatment":"4","name":"0000000422","specialMonitor":"否","defaultUnit":"EAE","whetherPartRecognize":" ","partEnvProtectionCategory":"Q/S0002+BF","absorptionShaftAngle":"3","partInspectionStandard":"特殊标准-Amazon","MtlNumofPOLBtn":"5","partCostUnit":"人民币","createType":"原材料","partIncomingInspection":"IQC","polarizerType":"NV","roottype":"Material","number":"0000011835","partSupplier":"1231","materialClassification":"INDT","partNote":"12312","partApplicationReason":"12312","partSize":"1231","finishedGoodType":"W123","source":"make","partMainSpecification":"2","isSecondSupplier":"否","partNumberEffectiveSite":"F10（武汉天马）","partRecognize":"是"}]}
            var newPubArr=[];
            for(var j=0;j<publicText.length;j++){
                newPubArr.push(publicText[j])
            }
            newPubArr.push.apply(newPubArr,publicClass);
           if(classtype=="SemiFinishedGood"){
               var Title="<thead><tr><td title='序号'><span>序号</span></td><td title='物料编号'><span>物料编号</span></td><td title='半成品分类'><span>半成品分类</span></td><td title='名称'><span>名称</span></td>";
               for(var i=0;i<newPubArr.length;i++){
                   if(newPubArr[i]!="半成品分类"){
                       Title+="<td title='"+newPubArr[i]+"'><span>"+newPubArr[i]+"</span></td>";
                   }
               }
            }else if(classtype=="Material"){
               var Title="<thead><tr><td title='序号'><span>序号</span></td><td title='物料编号'><span>物料编号</span></td><td title='名称'><span>名称</span></td>";
               for(var i=0;i<newPubArr.length;i++){
                   Title+="<td title='"+newPubArr[i]+"'><span>"+newPubArr[i]+"</span></td>";
               }
           }

            Title+="</tr></thead>";
            $(".tabRight").append(Title);
            var tableTd="<tbody>";
            if(classtype=="SemiFinishedGood"){
                //leftTypeList+="<tr><td><input type='checkbox'></td><td>"+datalist[n]["SemiFinishedGoodType"]+"</td></tr>";
                datalist=datalist.sort(compareUp(datalist,"roottype"))
            }else if(classtype=="Material"){
                // leftTypeList+="<tr><td><input type='checkbox'></td><td>"+datalist[n]["createType"]+"</td></tr>";
                datalist=datalist.sort(compareUp(datalist,"createType"))
            }
            for(var n=0;n<datalist.length;n++){
                var k=n+1;
                tableTd+="<tr><td style='background:#eee; opacity:0.6;filter:Alpha(opacity=60) '>"+k+"</td>";
                for(var v in dataListObj){
                    if(orEdt!=""&&orEdt=="yes"&&v=="number"){
                        var data=datalist[n]["numberA"]!=undefined?datalist[n]["numberA"]:'';
                        tableTd+="<td title='"+data+"'><input type='text' value='"+data+"'/></td>"
                    }else{
                        var data="";
                        if(v=="source"){
                            switch (datalist[n][v]){
                                case "make":
                                    data="制造"
                                    break;
                                case "buy":
                                    data="购买"
                                    break;
                                case "SUBCONTRACTOR":
                                    data="外加工"
                                    break;
                                case "PHANTOM":
                                    data="虚拟件"
                                    break;
                            }
                        }else{
                            data=datalist[n][v]!=undefined?datalist[n][v]:'';
                        }
                        //console.log(datalist[n].MtlNumofPOLBtn1)
                        if(v=="classificationATT"){
                            tableTd+="<td title='"+data+"'><a data-v='"+datalist[n].number+"'>查看</a></td>"
                        }else{
                            tableTd+="<td style='background:#eee; opacity:0.6;filter:Alpha(opacity=60) ' title='"+data+"'>"+data+"</td>"
                        }

                    }


                }
                tableTd+="</tr>";
            }
            tableTd+="</tbody>";
            $(".tabRight").append(tableTd);
            var height=$(".tabRight thead").height();
            $(".tabLeft thead tr").css("height",height+"px");
            var otdHeight=$(".tabRight tbody tr")/*.height()*/;
            for(var w=0;w<otdHeight.length;w++){
                var offHeight= $(".tabRight tbody tr")[w].clientHeight;
                $(".tabLeft tbody tr").eq(w).css({
                    "offsetHeight":otdHeight+"px"
                });
            }

        })
        $("body").unbind().on("click",".tabRight td a",function(){
            $(".createBox").css({
                "display":"block"
            })
            var datav=$(this).attr("data-v");
            if(datav!=undefined&&datav!=""){
                var params=datav;
                if(params!=""){
                    var url = "/MaterialsApplication/tmGetMaterialsClassification",
                        data="number="+encodeURIComponent(params);
                    $("#loading").css({
                        display:"block"
                    });
                    MaterialReverseAjax(url,data,suCallback);
                    var height=document.body.clientHeight;
                    var width =document.body.clientWidth;
                    $("#loading img").css({
                        "margin-left":width/2-25+"px",
                        "margin-top":height/2-25+"px"
                    })
                }
                function suCallback(str){
                    $("#loading").css({
                        display:"none"
                    });

                    if(str.datalist!=undefined&& JSON.stringify(str.datalist)!="{}"){
                        var dataLists=[];
                        for(var v in  str.datalist){
                            var objV={};
                            objV.keys=v;
                            objV.val=str.datalist[v];

                            dataLists.push(objV)
                        }
                        // dataLists.sort(compareUp("createtime"));
                       /* var heightform=$(".searchContainer").height()-20;
                        $(".formContent").css({
                            "max-height":heightform*0.85,
                            "overflow-y":"scroll"
                        });*/
                        window.historyList1=dataLists;
                        window.headers1=["序号","分类属性名称","分类属性值"]
                        window.widths1=[100,200,400];
                        // window.reportQuery="false";
                        $(".createBoxBG").empty().load('./newTable.html',"",function(){

                        });
                    }else{
                        $(".createBoxBG").empty();
                        layerFn("您查询的数据不存在！");
                    }
                }

            }
            $(".closeBOXDig").click(function(){
                $(".createBox").css({
                    "display":"none"
                })
            })
        })
        $(".submitMes").click(function(){
            var id=getQueryStringByNameTwo("itemOid")!=undefined?getQueryStringByNameTwo("itemOid"):"";
            var trLen=$(".tabRight tbody tr");
            var tdLen=$(".tabRight tbody tr:first-child td");
            var datalist=[];
            for(var i=0;i<trLen.length;i++){
                var obj={};
                for(var m=0;m<tdLen.length;m++){
                    var keys=$(".tabRight tbody tr").eq(i).find("td").eq(2).text();
                    obj[keys]=$(".tabRight tbody tr").eq(i).find("td").eq(1).find("input").val();
                }
                datalist.push(obj);
            }
            var url="/MaterialsApplication/tmEditMaterialsNumber";
            var data={
                oid:id,
                datalist:datalist
            };
            $("#loading").css({
                display:"block"
            });
            ajaxNewFn(url,data,function(str){
                var mesg=str.result!=undefined&&str.result!=""?str.result:"";
                if(mesg!=""){
                    layerFn(mesg)
                }else{
                    layerFn("提交成功",function(){
                        window.opener.location.href = window.opener.location.href;
                        window.location.href="about:blank";
                        window.opener=null;
                        window.open('','_self');
                        window.close();
                    })
                }
                $("#loading").css({
                    display:"none"
                });
            })
        })
    })()
</script>
</html>